package by.admonko.universaltesting.datamodel;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;

@Entity
public class UserTbl {

	/*
	 * id serial NOT NULL, user_name character varying(255) NOT NULL, owner_id
	 * integer, only_owner_upd boolean, user_group_id integer, user_passwd
	 * integer NOT NULL, is_admin boolean,
	 */

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer id;

	@Column
	private String userName;

	@ManyToOne(fetch = FetchType.LAZY, targetEntity = UserTbl.class)
	private UserTbl owner;

	@Column
	private Boolean onlyOwnerUpd;

	@JoinTable(name = "user_tbl_2_user_group", joinColumns = { @JoinColumn(name = "user_tbl_id") }, inverseJoinColumns = { @JoinColumn(name = "user_group_id") })
	@ManyToMany(targetEntity = UserGroup.class, fetch = FetchType.LAZY)
	private List<UserGroup> userGroup;

	@Column
	private Integer userPasswd;

	@Column
	private Boolean isAdmin;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public UserTbl getOwner() {
		return owner;
	}

	public void setOwner(UserTbl owner) {
		this.owner = owner;
	}

	public Boolean getOnlyOwnerUpd() {
		return onlyOwnerUpd;
	}

	public void setOnlyOwnerUpd(Boolean onlyOwnerUpd) {
		this.onlyOwnerUpd = onlyOwnerUpd;
	}

	public List<UserGroup> getUserGroup() {
		return userGroup;
	}

	public void setUserGroup(List<UserGroup> userGroup) {
		this.userGroup = userGroup;
	}

	public Integer getUserPasswd() {
		return userPasswd;
	}

	public void setUserPasswd(Integer userPasswd) {
		this.userPasswd = userPasswd;
	}

	public Boolean getIsAdmin() {
		return isAdmin;
	}

	public void setIsAdmin(Boolean isAdmin) {
		this.isAdmin = isAdmin;
	}

}
